<?php

namespace app\api\controller\v17;

use app\api\controller\v13\Auth2;
use app\common\cachemodel\GoddessBaseInfo;
use app\common\cachemodel\ZlGoddessState;

/**
 * 女神动态相关
 * @version 2.0.0
 * Class GoddessState
 */
class GoddessState extends Auth2
{
    /**
     * 女神动态首页
     * @throws \Exception
     */
    public function index()
    {
        $type = input('type/d', 1); //动态类型 1=>综合，2=>视频,3=>语音,4=>文章
        $page = input('page/d', 1);
        //获取女神动态列表
        $goddessState = (new ZlGoddessState())->getGoddessStateFromCache($this->user, $type - 1);
        //获取女神信息
        if ($page === 1 && $type == 1)
        {
            $goddessInfo = (new GoddessBaseInfo())->getInfo(['notice_img1', 'target1', 'link1']);
            //若未开启苹果审核且有公告，则将公告追加进动态列表中
            if (!$this->is_apple_check && $goddessInfo['notice_img1'])
            {
                $notice = [
                    'type' => 5,
                    'thumb' => $goddessInfo['notice_img1'] ?? '',
                    'target' => $goddessInfo['target1'] ?? '',
                    'link' => $goddessInfo['link1'] ?? '',
                ];
                array_unshift($goddessState['data'], $notice);
            }
        }
        return show(config('code.success'), '获取成功', $goddessState);
    }
}
